<?php
//------- INIT
$sql = new mysqli("localhost", "intranet", $dbPassword, "intranet");
if ($sql->connect_errno) {
    echo "Failed to connect to MySQL: " . $sql->connect_error;
}

//------- Functions

function query($statement) {
	global $sql;
	if (!$sql) {
		echo "Failed to initialize mysqli";
		return false;
	}
	$res = $sql->query($statement);
	if (!$res) {
		echo "Failed to run query: (" . $sql->errno . ") " . $sql->error;
	}
	return $res;
}

function closeDB() {
	global $sql;
	$sql->close();
}

function top($title = "USU Intranet") {
	echo "<html><head><title>$title</title></head><body>";
}

function bottom() {
	closeDB();
	echo "</body></html>";
}
?>